//
//  ZYCProtalNoticePushPeopleSeacherView.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/26.
//

#import "ZYCProtalNoticePushPeopleSeacherView.h"
#import "ZYCProtalNoticePushPeopleCell.h"
#import "ZYCStuLeavePersonCell.h"

@interface ZYCProtalNoticePushPeopleSeacherView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end
@implementation ZYCProtalNoticePushPeopleSeacherView

- (void)reload{
    [self.tableView reloadData];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.tableView];
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
    }
    return self;
}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ZYCRoleTreeModel *model = self.dataSource[indexPath.row];
    ZYCStuLeavePersonCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ZYCStuLeavePersonCell class]) forIndexPath:indexPath];
    cell.model = model;
//    if (selectIndexPath == indexPath) {
//        cell.isSelect = YES;
//    }else{
//        cell.isSelect = NO;
//    }
    return cell;

}

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    ZYCRoleTreeModel *model = _searchActive ? _requltData[indexPath.section][indexPath.row] : _tableData[indexPath.section][indexPath.row];
//    ZYCStuLeavePersonCell *cell = [tableView cellForRowAtIndexPath:selectIndexPath];
//    cell.isSelect = NO;
//    selectIndexPath = indexPath;
//    self.selectModel = model;
//    NSLog(@"选中的人:%@",self.selectModel);
//
//    if (self.selectStuBlock) {
//        self.selectStuBlock(model);
//    };
//    [self.tableView reloadData];
//}

#pragma mark - Table View Delegate
//-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
//    UILabel * tempLab = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, kScreenWidth, 30)];
////    tempLab.textAlignment = NSTextAlignmentCenter;
//    tempLab.text = _searchActive ? _requltIndexData[section] : _tableIndexData[section];
//    tempLab.backgroundColor = [UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];
//    return tempLab;
//}


-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 48.0f;
}

-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 48.0f;
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[ZYCProtalNoticePushPeopleCell class] forCellReuseIdentifier:NSStringFromClass([ZYCProtalNoticePushPeopleCell class])];
        [_tableView registerClass:[ZYCStuLeavePersonCell class] forCellReuseIdentifier:NSStringFromClass([ZYCStuLeavePersonCell class])];
        if (@available(iOS 15.0, *)) {
            _tableView.sectionHeaderTopPadding = 0;
        }
    }
    return _tableView;
}


@end
